/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.unipar.oficina.service.cadastros;

import br.com.unipar.oficina.modelo.cadastros.Cargo;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

/**
 *
 * @author Thiago Marques
 */
@Service("cargoService")
public class CargoServiceImpl
        extends GenericServiceImpl<Cargo>
        implements CargoService {

    @Override
    public List<Cargo> consultar(String nomeCargo) {
        Criteria crit = ((Session) entityManager.getDelegate()).createCriteria(Cargo.class);
        if (nomeCargo != null) {
            crit.add(Restrictions.ilike("nomeCargo", nomeCargo, MatchMode.ANYWHERE));
        }
        return crit.list();
    }

    @Override
    public Cargo getByIdCargo(Long id) {
        return entityManager.find(Cargo.class, id);
    }


    
}
